<?php
$active=array('active','','','','','','');
include 'header.php';
include '../c/config.php';
$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqliTwo->error);}



if (isset($_GET['p'])) {
    $page=$_GET['p'];
}else{
    $page=1;
}
$pageSize=10;
$query_count = $mysqli->query("select count(id) as count from users ");
$row=$query_count->fetch_array();
$total=$row['count'];
$total_page=1;
if ($total) {
    if($total % $pageSize){
        $total_page=(int)($total/$pageSize)+1;
    }else{
        $total_page=($total/$pageSize);
    }
}
$pageUrl='?&c=home&p=';
$query=$mysqli->query("SELECT * FROM users  order by id desc limit ".($page-1)*$pageSize.", $pageSize ");


?>
	<div class="wrap js-check-wrap">
        <div style="width:100%;height:40px;">
			<a href="?c=home-down" class="btn btn-primary">导出数据</a>
		</div>
		<form class="js-ajax-form" action="" method="post">
			<table class="table table-hover table-bordered table-list">
				<thead>
					<tr>
						<th width="50">Openid</th>
						<th width="50">昵称</th>
						<th width="50">头像</th>
						<th width="50">是否扫50领券</th>
						<th width="50">电视200元</th>
						<th width="50">空调200元</th>
						<th width="50">空调300元</th>
						<th width="50">冰箱200元</th>
						<th width="50">洗衣机200元</th>
						<th width="50">洗衣机300元</th>
						<th width="50">参与时间</th>
					</tr>
				</thead>
				<?php  
				while ($list=$query->fetch_assoc()){
					$queryS50=$mysqli->query("SELECT id FROM s50 where openid='".$list['openid']."' limit 0,1");
					$S50='否';
					if($queryS50->num_rows>0){
						$S50='是';
					}
					$ds200='';
					$querylds2=$mysqli->query("SELECT id FROM l_ds2 where openid='".$list['openid']."' limit 0,1");
					if($querylds2->num_rows>0){
						$lds2Info=$querylds2->fetch_array();
						$lds2Id=$lds2Info['id'];
						$queryds200=$mysqli->query("SELECT name FROM ds200 where id='".$lds2Id."' limit 0,1");
						$ds200Info=$queryds200->fetch_array(); 
						$ds200=$ds200Info['name'];
					}
					$kt200='';
					$querylkt2=$mysqli->query("SELECT id FROM l_kt2 where openid='".$list['openid']."' limit 0,1");
					if($querylkt2->num_rows>0){
						$lkt2Info=$querylkt2->fetch_array();
						$lkt2Id=$lkt2Info['id'];
						$querykt200=$mysqli->query("SELECT name FROM kt200 where id='".$lkt2Id."' limit 0,1");
						$kt200Info=$querykt200->fetch_array();
						$kt200=$kt200Info['name'];
					}
					
					$kt300='';
					$querylkt3=$mysqli->query("SELECT id FROM l_kt3 where openid='".$list['openid']."' limit 0,1");
					if($querylkt3->num_rows>0){
						$lkt3Info=$querylkt3->fetch_array();
						$lkt3Id=$lkt3Info['id'];
						$querykt300=$mysqli->query("SELECT name FROM kt300 where id='".$lkt3Id."' limit 0,1");
						$kt300Info=$querykt300->fetch_array();
						$kt300=$kt300Info['name'];
					}
					
					$bx200='';
					$querylbx2=$mysqli->query("SELECT id FROM l_bx2 where openid='".$list['openid']."' limit 0,1");
					if($querylbx2->num_rows>0){
						$lbx2Info=$querylbx2->fetch_array();
						$lbx2Id=$lbx2Info['id'];
						$querybx200=$mysqli->query("SELECT name FROM bx200 where id='".$lbx2Id."' limit 0,1");
						$bx200Info=$querybx200->fetch_array();
						$bx200=$bx200Info['name'];
					}
					
					$xyj200='';
					$querylxyj2=$mysqli->query("SELECT id FROM l_xyj where openid='".$list['openid']."' limit 0,1");
					if($querylxyj2->num_rows>0){
						$lxyj2Info=$querylxyj2->fetch_array();
						$lxyj2Id=$lxyj2Info['id'];
						$querxyj200=$mysqli->query("SELECT name FROM xyj200 where id='".$lxyj2Id."' limit 0,1");
						$xyj200Info=$querxyj200->fetch_array();
						$xyj200=$xyj200Info['name'];
					}
					
					$xyj300='';
					$querylxyj3=$mysqli->query("SELECT id FROM l_xyj3 where openid='".$list['openid']."' limit 0,1");
					if($querylxyj3->num_rows>0){
						$lxyj3Info=$querylxyj3->fetch_array();
						$lxyj3Id=$lxyj3Info['id'];
						$querxyj300=$mysqli->query("SELECT name FROM xyj300 where id='".$lxyj3Id."' limit 0,1");
						$xyj300Info=$querxyj300->fetch_array();
						$xyj300=$xyj300Info['name'];
					}
					
 
				         ?>
				<tr>
				        <td><b><?php echo $list['openid']  ?></b></td>
						<td><b><?php echo base64_decode($list['nickname']) ?></b></td>
						<td><b><img src="<?php echo $list['avatar'] ?>" width="60" /></b></td>
						<td><b><?php echo $S50; ?></b></td>
						<td><b><?php echo $ds200; ?></b></td>
						<td><b><?php echo $kt200; ?></b></td>
						<td><b><?php echo $kt300; ?></b></td>
						<td><b><?php echo $bx200; ?></b></td>
						<td><b><?php echo $xyj200; ?></b></td>
						<td><b><?php echo $xyj300; ?></b></td>
						<td><b><?php echo $list['createtime'] ?></b></td>
					</tr>
			    <?php } 
			    
			    
			    $mysqli->close();
			    ?>		
					 
			</table>
			 
		</form>
		<?php  include('_page.php'); ?>
	</div>



<?php
include 'foot.php';
?>